package day13;

import java.awt.Button;
import java.awt.GridLayout;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

public class JFrameDemo6 {
	public static void main(String[] args) {
		JFrame frame = new JFrame("选择");
		JPanel panel = new JPanel();
		frame.add(panel);
		panel.setLayout(new GridLayout(3, 1));
		JPanel panel1 = new JPanel();
		JLabel sportlabel = new JLabel("你喜欢的运动");
		JCheckBox checkBox1 = new JCheckBox("足球");
		JCheckBox checkBox2 = new JCheckBox("篮球");
		JCheckBox checkBox3 = new JCheckBox("网球");
		panel1.add(sportlabel);
		panel1.add(checkBox1);
		panel1.add(checkBox2);
		panel1.add(checkBox3);
		JPanel panel2 = new JPanel();
		JLabel genderlabel = new JLabel("你的性别");
		JRadioButton radioButton1 = new JRadioButton("男");
		JRadioButton radioButton2 = new JRadioButton("女");
		//实现只能单选
		ButtonGroup buttonGroup = new ButtonGroup();
		buttonGroup.add(radioButton1);
		buttonGroup.add(radioButton2);
		panel2.add(genderlabel);
		panel2.add(radioButton1);
		panel2.add(radioButton2);
		JPanel panel3 = new JPanel();
		JButton button1 = new JButton("确定");
		JButton button2 = new JButton("取消");
		panel3.add(button1);
		panel3.add(button2);
		panel.add(panel1);
		panel.add(panel2);
		panel.add(panel3);
		frame.setSize(500, 200);
		frame.setLocation(450, 450);
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
